package c.e.a.b.f.b;

import b.i.b.f;

/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
public final class x implements Runnable {
    public final /* synthetic */ String a;
    public final /* synthetic */ long b;
    public final /* synthetic */ a c;

    public x(a aVar, String str, long j) {
        this.c = aVar;
        this.a = str;
        this.b = j;
    }

    public final void run() {
        a aVar = this.c;
        String str = this.a;
        long j = this.b;
        aVar.g();
        f.N(str);
        Integer num = (Integer) aVar.c.get(str);
        if (num != null) {
            i7 w = aVar.q().w(false);
            int intValue = num.intValue() - 1;
            if (intValue == 0) {
                long longValue;
                aVar.c.remove(str);
                Long l = (Long) aVar.b.get(str);
                if (l == null) {
                    aVar.d().f.a("First ad unit exposure time was never set");
                } else {
                    longValue = j - l.longValue();
                    aVar.b.remove(str);
                    aVar.w(str, longValue, w);
                }
                if (aVar.c.isEmpty()) {
                    longValue = aVar.d;
                    if (longValue == 0) {
                        aVar.d().f.a("First ad exposure time was never set");
                        return;
                    }
                    aVar.u(j - longValue, w);
                    aVar.d = 0;
                    return;
                }
                return;
            }
            aVar.c.put(str, Integer.valueOf(intValue));
            return;
        }
        aVar.d().f.b("Call to endAdUnitExposure for unknown ad unit id", str);
    }
}
